//
//  LoadingLayer.m
//  Box2dDemo
//
//  Created by Thi Huynh on 9/6/12.
//  Copyright (c) 2012 __MyCompanyName__. All rights reserved.
//

#import "LoadingLayer.h"

@implementation LoadingLayer

-(id)init
{
    self = [super init];
    if(self)
    {
        [self schedule:@selector(update:)];
        [self setIsTouchEnabled:NO];
    }
    return self;
}

#pragma mark - create sections

- (void)createLoadingWithPos:(CGPoint)pos
{
    [self setPosition:pos];
    [self createComponent];
}

- (void)createComponent
{
    _loadingBg = [CCSprite spriteWithFile:IMG_LOADING];
    [_loadingBg setPosition:self.position];
    [_loadingBg setVisible:YES];
    [self addChild:_loadingBg];
    //TODO : create loading icon , loading label
    //
    //
}

#pragma mark - update section 
- (void)update:(ccTime)dt
{
    if(![MainGame getInstance].gameProperty.isLoading)
    {
        //TODO: close loading
    }
        
}

#pragma mark - dealloc section
- (void)dealloc
{
    if(_loadingBg)
    {
        [_loadingBg release];
        _loadingBg = nil;
    }
    if(_loadingIcon)
    {
        [_loadingIcon release];
        _loadingIcon = nil;
    }
    if(_loadinglabel)
    {
        [_loadinglabel release];
        _loadinglabel = nil;
    }
    
    [super dealloc];
    
}
@end
